<template>

</template>
<script>
	import config from "@/config/config.js";
	import xcHttpUtils from '@/library/xcore/js/XcHttpUtils.js';
	import xcViewUtils from '@/library/xcore/js/XcViewUtils.js';
	import {
		xsStringUtils,
		xsDateUtils,
		xsArrayUtils
	} from 'xstack-for-javascript';

	export default {
		props: {
			fstatusList: {
				type: Array,
				default: []
			},
			flogicList: {
				type: Array,
				default: []
			},
			data: {
				type: Object,
				default: {}
			},
		},
		watch: {
			'fstatusList': {
				handler(newVal, oldVal) {
					let that = this;
				},
			},
		},
		data() {
			return {
				config: config,
				xsStringUtils: xsStringUtils,
				xsDateUtils: xsDateUtils,
				xsArrayUtils: xsArrayUtils,
				sp: {
					clickFstatusId: null,
					callbackFunc: null
				},
				sr: {},
				control: {}
			}
		},
		created() {
			let that = this;
			that.xinit();
		},
		methods: {
			xinit() {
				let that = this;
			},
			public_show(clickFstatusId, callbackFunc) {
				let that = this;
				that.sp.clickFstatusId = clickFstatusId;
				that.sp.callbackFunc = callbackFunc;

				// update all->other flogic
				let otherLogic = null;
				for (let i = 0, j = that.flogicList.length; i < j; i++) {
					let item = that.flogicList[i];
					if(item["flowfstatus_id"] == clickFstatusId){
						if(item["logictype"]=="all"){
							that.flogicList[i]["logictype"] = "other";
							that.flogicList[i]["name"] = "其他情况";
							otherLogic = that.flogicList[i];
							break;
						}else if(item["logictype"]=="other"){
							otherLogic = that.flogicList[i];
							break;
						}
					}
				}

				// add to flogic
				let tt = that.flogicList.length + 1;
				that.flogicList.push({
					"id": 300 + tt,
					"logictype": "to",
					"name": "分支逻辑",
					"flowfstatus_id": clickFstatusId,
					"pass_fstatus_id": otherLogic.pass_fstatus_id
				});

				that.sp.callbackFunc();
			},
			public_reset() {
				let that = this;
				that.public_show();
			},
			public_close() {
				let that = this;
				that.control.visible = false;
			},
		}
	}
</script>

<style lang="scss">
	.xp-content {
		padding-bottom: $uni-spacing-col-base;
	}
</style>